package logic

import (
	"context"
	"doctor-medicine-system/dockerrpc/dockerrpc"
	"doctor-medicine-system/dockerrpc/internal/svc"
	"doctor-medicine-system/model/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type MedicineShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMedicineShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MedicineShowLogic {
	return &MedicineShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 药品详情
func (l *MedicineShowLogic) MedicineShow(in *dockerrpc.MedicineShowRequest) (*dockerrpc.MedicineShowResponse, error) {
	// todo: add your logic here and delete this line

	var medicine mysql.Medicine

	err := medicine.MedicineShow(mysql.DB, in.MedicineId)
	if err != nil {
		return nil, err
	}

	return &dockerrpc.MedicineShowResponse{
		MedicineId: int64(medicine.ID),
		Name:       medicine.Name,
		Style:      medicine.Style,
		Address:    medicine.Address,
		Good:       medicine.Good,
		Num:        medicine.Num,
		Work:       medicine.Work,
		DockerId:   int64(medicine.DockerId),
	}, nil
}
